package me.flyray.crm.core.modules.netty.handlers;


import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.netty.channel.Channel;

/** 
* @author: bolei
* @date：2018年9月11日 下午1:20:37 
* @description：类说明
*/

public class NettyChannelMap {
	
	private static Logger logger = LoggerFactory.getLogger(NettyChannelMap.class);
	
	private static Map<String, Channel> map = new ConcurrentHashMap<String, Channel>();
	  public static void add(String clientId,Channel channel){
 
	        map.put(clientId,channel);
 
	    }
 
	    public static Channel get(String clientId){
 
	       return map.get(clientId);
 
	    }
 
	    public static void remove(Channel channel){
 
	        for (Map.Entry entry:map.entrySet()){
	        	logger.info("断开连接。。{}"+entry.getValue());
	            if (entry.getValue()==channel){
	            	System.out.println("");
	            	logger.info("移除连接。。{}"+entry.getKey());
	                map.remove(entry.getKey());
 
	            }
 
	        }
 
	    }
 
}

